# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Fabian Affolter <fabian@affolter-engineering.ch>
pkgname=cracklib
pkgver=2.9.7
pkgrel=2
pkgdesc="A library used to enforce strong passwords"
url="https://github.com/cracklib/cracklib"
arch="all"
license="LGPL-2.0-or-later"
triggers="$pkgname.trigger=/usr/share/cracklib"
makedepends="zlib-dev"
subpackages="$pkgname-dev $pkgname-words::noarch"
source="https://github.com/cracklib/cracklib/releases/download/v$pkgver/cracklib-$pkgver.tar.bz2
	https://github.com/cracklib/cracklib/releases/download/v$pkgver/cracklib-words-$pkgver.gz"

# secfixes:
#   2.9.7-r0:
#     - CVE-2016-6318

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--without-python \
		--disable-nls
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	# Remove static lib
	rm "$pkgdir"/usr/lib/libcrack.a

	for x in "$pkgdir"/usr/share/cracklib/*; do
		gzip -c "$x" > "$x".gz
		rm "$x"
	done
}

words() {
	pkgdesc="Large list of words for crack/cracklib"
	license="Public-Domain"
	depends=""

	cd "$srcdir"
	install -m644 -D $pkgname-words-$pkgver.gz "$subpkgdir"/usr/share/cracklib/$pkgname-words.gz
}

sha512sums="f6bf65ac092ba46ff78ddbc115692260fb76dc71219cd679d2ea935ebfb9e709fbb30259a7406743ed00dbdc415335b3ac9d9fcba1d204ea36d5eb96bf1333a2  cracklib-2.9.7.tar.bz2
1fa34b0a2e16d6906982b248f1757bf5bf8154d8d7e8bab94a4ac25080c41434d3828a2c8dd5065e9be586f36480ab70375f09e0bb64eb495d96a460619e2bae  cracklib-words-2.9.7.gz"
